<template>
	<view class="context">
		<!-- tab -->
		<view class="sub-tab"> 
			<button v-for="(item,index) in data" :key="index" @click="changeCurrent(index)" class="sub-tab-btn"
			:class="{'active-btn':current == index}">{{item.name}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current:0
			}
		},
		props:{
			data:{
				type:Array
			}
		},
		methods: {
			changeCurrent(index){
				this.current = index
				this.$emit("subTabChange",index)
			},
			returnStyle(v){
				if(v){
					return "width:'100%',backgroundColor:'#2A96EE'"
				}else{
					return "width:'100%',backgroundColor:'#fff',color:'#000'"
				}
			}
		},
		onReady() {},
		onLoad: function(v) {}
	}
</script>

<style lang="scss" scoped>
	.box{
		display: flex;
		background-color: #fff;
		.box-item{
			font-size: 32rpx;
			margin-right: 20rpx;
			padding: 20rpx;
			position: relative;
			.box-item-select{
				font-size: 36rpx;
				font-weight: bold;
			}
			.border-bottom{
				position: absolute;
				top: 55rpx;
				width: 106rpx;
				height: 8rpx;
				background: #2A96EE;
				border-radius: 2rpx;
				opacity: 0.8;
			}
		}
	}
	
	.sub-tab{
		display: flex;
		width: 100%;
		.sub-tab-btn{
			margin-right: 10rpx;
			width: 100%;
			height: 68rpx;
			line-height: 68rpx;
			font-size: 28rpx;
		}
		.active-btn{
			background-color: #2A96EE;
			color: #fff;
		}
	}
	
</style>
